// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import App from "./App";
import router from "./router";
import "../src/assets/global.css";
import "./plugins/element.js"; /* 导入element ui */
import "element-ui/lib/theme-chalk/index.css"; //导入element样式
import "../src/assets/fonts/iconfont.css";
import TreeTable from "vue-table-with-tree-grid";
import VueQuillEditor from "vue-quill-editor"; //导入富文本编辑器
// require styles 导入富文本编辑器样式css
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
// 引入NProfress进度条
import NProgress from "nprogress";
import "nprogress/nprogress.css";

import axios from "axios";
import { config } from "shelljs";
// axios.defaults.baseURL = "https://www.liulongbin.top:8888/api/private/v1/";
// axios.defaults.baseURL = "http://43.143.0.76:8889/api/private/v1";
// axios.defaults.baseURL = "http://47.108.251.106:8881/api/private/v1/";
// axios.defaults.baseURL = "http://127.0.0.1:8888/api/private/v1/";
axios.defaults.baseURL = "http://175.27.228.178:3434/api/private/v1/";
// axios.defaults.baseURL = "http://120.78.137.246:8888/api/private/v1/";


axios.interceptors.request.use(function (config) {
   NProgress.start(); //展示加载进度条--// 在request中展示进度条--- 显示： NProgress.start()
   // console.log(config);
   // 除了login请求接口，其他都需要授权，才能正常请求数据，所以axios请求拦截器添加token，保证获取数据的权限
   // 里面有 headers 属性，手动保存在session本地，把这个令牌给token保存下来
   // 必须是 return config
   config.headers.Authorization = window.sessionStorage.getItem("token");
   return config;
});
// 在response中隐藏进度条-- 隐藏： Nprogress.dode()
axios.interceptors.response.use((config) => {
   NProgress.done(); //隐藏进度条
   return config;
});

Vue.prototype.$http = axios;

Vue.config.productionTip = false;
Vue.component("tree-table", TreeTable);

Vue.use(VueQuillEditor); //将富文本编辑器组件全局注册

Vue.filter("dateFormat", function (originVal) {
   const dt = new Date(originVal);
   const y = dt.getFullYear();
   const m = (dt.getMonth() + 1 + "").padStart(2, "0");
   const d = (dt.getDay() + "").padStart(2, "0");

   const hh = (dt.getHours() + "").padStart(2, "0");
   const mm = (dt.getMinutes() + "").padStart(2, "0");
   const ss = (dt.getSeconds() + "").padStart(2, "0");
   // return `yyyy-mm-dd hh:mm:ss` //一样的写法在下面
   return `${y}-${m}-${d} ${hh}:${mm}:${ss}`;
});

/* eslint-disable no-new */
new Vue({
   el: "#app",
   router,
   components: { App },
   template: "<App/>",
});
